package com.yu.waterstation.app.moudles.other;

import com.yu.waterstation.common.common.constant.Const;
import com.yu.waterstation.common.common.util.result.Result;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "反馈中心")
@RestController
public class AdviceController {

    @Resource
    private RedisTemplate redisTemplate;

    // 用户的反馈建议
    @PostMapping("/advice")
    public Result<String> giveAdvice(String advice) {
        if (StringUtils.isEmpty(advice))
            return Result.fail("内容不能为空");
        redisTemplate.opsForList().leftPush(Const.CONST_user_advice_list, advice);
        return Result.ok();
    }
}
